<?php
/**
 * Name: IndexController.php.
 * Author: JiaMeng <666@majiameng.com>
 * Date: 2018/4/16 14:12
 * Description: IndexController.php.
 */
namespace App\Http\Controllers\Api\Payment;

use App\Http\Controllers\BaseController;
use App\Http\Requests\Order\CloseRequest;
use App\Http\Requests\Order\CreateRequest;
use App\Http\Requests\Order\GetPayStatusRequest;
use App\Http\Requests\Order\RefundRequest;
use App\Services\CommonReturn;
use App\Services\CommonServices;
use App\Services\Payment\Order\OrderServices;
use Illuminate\Contracts\View\Factory;
use Illuminate\View\View;

class OrderController extends BaseController
{

    /**
     * Description:  创建订单
     * @author: JiaMeng <666@majiameng.com>
     * Updater:
     * @return Factory|View
     */
    public function create(OrderServices $services,CreateRequest $request)
    {
        $params = $request->filterData();
        CommonServices::writeLog($params,__FUNCTION__);

        $result = $services->create($params);
        CommonReturn::success($result);
    }

    /**
     * 获取订单支付状态
     * @return array
     */
    public function getPayStatus(OrderServices $services,GetPayStatusRequest $request){
        $params = $request->filterData();
        CommonServices::writeLog($params,__FUNCTION__);

        $result = $services->getPayStatus($params);
        CommonReturn::success($result);
    }

    /**
     * 退款
     * @return array
     */
    public function refund(OrderServices $services,RefundRequest $request){
        $params = $request->filterData();
        CommonServices::writeLog($params,__FUNCTION__);

        $result = $services->refund($params);
        CommonReturn::success($result);
    }

    /**
     * 关闭订单
     * @return array
     */
    public function close(OrderServices $services,CloseRequest $request){
        $params = $request->filterData();
        CommonServices::writeLog($params,__FUNCTION__);

        $result = $services->close($params);
        CommonReturn::success($result);
    }


}
